//
//  NSNetwork.h
//  erhuo
//
//  Created by Jingru Nie on 14/12/30.
//  Copyright (c) 2014年 集易（北京）科技有限公司. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef enum {
    _NETWORK_DATA_TYPE_JSON_ = 0,
    _NETWORK_DATA_TYPE_TEXT_ = 1,
    _NETWORK_DATA_TYPE_PNG_ = 2
} _NETWORK_DATA_TYPE_;

typedef enum {
    _NETWORK_METHOD_GET_ = 1,
    _NETWORK_METHOD_POST_ = 2
} _NETWORK_METHOD_;

@interface NSNetwork : NSObject

- (NSNetwork *)initWithURL:(NSURL *)url
                withMethod:(_NETWORK_METHOD_)method
                  withData:(NSDictionary *)data
                  withType:(_NETWORK_DATA_TYPE_)type;

- (NSNetwork *)initWithURL:(NSURL *)url
                withMethod:(_NETWORK_METHOD_)method;

typedef void (^_NETWORK_RESPONSE_FINISH_)(NSURLResponse *response, NSData *result, NSError *error);
- (void)sendRequest:(_NETWORK_RESPONSE_FINISH_)finishied;

- (void)setURL:(NSURL *)url;
- (void)setMethod:(NSString *)method;
- (void)setData:(NSDictionary *)data
       withType:(_NETWORK_DATA_TYPE_)type;
- (void)setData:(NSData *)data;

- (void)setCachePolicy:(NSURLRequestCachePolicy)policy;
- (void)setTimeoutInterval:(NSTimeInterval)timeinterval;
- (void)setCookies:(NSHTTPCookie *)cookies;

@end
